﻿using System;
using System.Collections;
using AMS.Core.Entities;
using VitCode.Castle.DataAccess;

namespace AMS.Web.UserControls
{
    public partial class ddlBindObject : System.Web.UI.UserControl
    {
         CastleAccess m_Acc = new CastleAccess();

         public string Text
         {
             get
             {
                 if (ddlList.SelectedValue.Length > 0 && ddlList.SelectedValue.Length == 36)
                 {
                    return ddlList.SelectedValue;
                 }
                 return "";
            }
             set { ddlList.Text = value; }
         }

        private string m_ClassName;

        public virtual string  ClassName
        {
            get { return m_ClassName; }
            set { m_ClassName = value; }
        }

        private string m_ShowProName =  "Name";

        public string ShowProName
        {
            get { return m_ShowProName; }
            set { m_ShowProName = value; }
        }

        private string m_KeyProName = "Id";

        public string KeyProName
        {
            get { return m_KeyProName; }
            set { m_KeyProName = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            IList objList = m_Acc.GetObjectList(m_ClassName);

            ddlList.DataSource = objList;
            ddlList.DataTextField = "Name";
            ddlList.DataValueField = "Id";
            ddlList.DataBind();
         
        }

  
    }
}